package org.apache.mina.example.http;

import java.net.InetSocketAddress;

import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.http.HttpClientCodec;
import org.apache.mina.transport.socket.nio.NioSocketConnector;

public class Conn
{

    public static void main(String[] args)
    {
        NioSocketConnector connector = new NioSocketConnector();

        connector.getSessionConfig().setKeepAlive(false);

        connector.getSessionConfig().setTcpNoDelay(true);

        connector.setConnectTimeoutCheckInterval(5000);

        connector.getFilterChain().addLast("codec", new HttpClientCodec());

        connector.setHandler(new MyHttpHandler());
        
        for(int i=0;i<100000;i++){
            ConnectFuture connectFuture = connector.connect(new InetSocketAddress("www.baidu.com", 80));
        }
        
        System.out.println("finish");
        
        connector.dispose(true);
        

    }
}
